package net.ewon.avatar.common.util;

public class OSUtil {

	public static String getOsName() {
		return System.getProperties().getProperty("os.name");
	}

	/**
	 * 
	 * @return true if it is a mac.
	 */
	public static boolean isMacOs() {
		final String prefix = "mac";
		return isOsPrefix(prefix);
	}

	/**
	 * 
	 * @return true if it is linux
	 */
	public static boolean isLinux() {
		return isOsPrefix("linux");
	}

	/**
	 * 
	 * @return true if it is Windows
	 */
	public static boolean isWindows() {
		return isOsPrefix("win");
	}

	private static boolean isOsPrefix(final String prefix) {
		String os = getOsName();
		return os != null && os.toLowerCase().startsWith(prefix);
	}

}
